# SQLite3 example in Python

import sqlite3

# Connect to a database (or create one if it doesn't exist)
conn = sqlite3.connect('example.db')

# Create a cursor object to interact with the database
c = conn.cursor()

# Create a table
c.execute('''CREATE TABLE IF NOT EXISTS users
             (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)''')

# Insert a row of data
c.execute("INSERT INTO users (name, age) VALUES ('John Doe', 30)")

# Save (commit) the changes
conn.commit()

# Query the database
for row in c.execute('SELECT * FROM users ORDER BY name'):
    print(row)

# Close the connection
conn.close()
